<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8" />
        <link rel="stylesheet" href="styles/style.css">
        <link rel="stylesheet" href="styles/theme/atom-one-dark.css">
        <title>例子7-JS进阶（一）</title>
    </head>
    <body class="cols">
        <pre>
            <code>
                    // 例子7

                    var a = 20;

                    function test() {
                        var b = a + 10;

                        function innerTest() {
                            var c = 10;
                            return b + c;
                        }

                        return innerTest();
                    }

                    test();

            </code>
        </pre>
        <pre>
            <code>
                    // 全局、函数test()、函数innerTest的执行上下文分别创建
                    // 我们设定它们的变量对象分别为VO(global)、VO(test)和VO(innerTest)

                     windowEC = {
                         VO: {...}, // 变量对象
                         scopeChain: [VO(global)], // 作用域链
                         this: window
                     }

                     testEC = {
                         VO: {...}, // 变量对象
                         scopeChain: [VO(test), VO(global)], // 作用域链
                         this: window
                     }

                     innerTestEC = {
                         VO: {...}, // 变量对象
                         scopeChain: [VO(innerTest), VO(test), VO(global)], // 作用域链
                         this: window
                     }

            </code>
        </pre>
        <script src="scripts/libs/highlight.pack.js"></script>
        <script src="scripts/7.js"></script>
        <script>
            hljs.initHighlightingOnLoad();
        </script>
    </body>
</html>